<?php

header("Content-type: text/html; charset=utf-8");

$debug = 0;
if ($debug) {
    $arr = array('err' => 0, 'lizhi_content' => "自定义公告", 'lizhi_author' => "作者");
    exit(json_encode($arr));
}


$url = "https://v1.hitokoto.cn/?encode=json";
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
$res = json_decode($result, true);


if ($res['from'] == "原创" || $res['from'] == "自己") $res['from'] = "Hitokoto";
$arr = array('err' => 0, 'lizhi_content' => $res['hitokoto'], 'lizhi_author' => $res['from']);

exit(json_encode($arr));
